package topcoder;

public class PointErasingTwo {

	public int getMaximum(int[] y){
		int max = 0;
		
		for(int x1 = 0; x1 <= y.length-3; x1++){
			for(int x2 = x1+2; x2 <= y.length-1; x2++){
				int count = 0;
				for(int x3 = x1; x3 <= x2; x3++){
					if((y[x3]<y[x1] && y[x3]>y[x2]) || (y[x3]>y[x1] && y[x3]<y[x2]))
						count++;
				}
				if(count>max)
					max=count;
			}
		}
		
		return max;
	}
}
